package com.hxm.appGenealogy.Function;

import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.hxm.appGenealogy.config.queryVo.QueryWrapperVO;
import com.hxm.appGenealogy.entity.BrothersSistersPeople;
import com.hxm.appGenealogy.mapper.BrothersSistersPeopleMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class BrothersSistersPeopleFunction {

    @Autowired
    private BrothersSistersPeopleMapper brothersSistersPeopleMapper;

    /**
     * 添加兄弟姐妹;
     * @param brothersSistersPeople
     * @return
     */
    public BrothersSistersPeople insert(BrothersSistersPeople brothersSistersPeople){
        brothersSistersPeopleMapper.insert(brothersSistersPeople);
        return brothersSistersPeople;
    }

    /**
     * 根据id查询兄弟的额信息;
     * @param id
     * @return
     */
    public BrothersSistersPeople selectByid(Long id){
        BrothersSistersPeople brothersSistersPeople = brothersSistersPeopleMapper.selectById(id);
        return  brothersSistersPeople;
    }

    /**
     *根据id进行修改;
     */
    public void updateByid(BrothersSistersPeople brothersSistersPeople){
        brothersSistersPeopleMapper.updateById(brothersSistersPeople);
    }

    /**
     * 条件查询;
     */
    public List<BrothersSistersPeople> slectStringQuery(String query){
        QueryWrapper<BrothersSistersPeople> queryWrapper = QueryWrapperVO.getQueryWrapper(query);
        List <BrothersSistersPeople>list = brothersSistersPeopleMapper.selectList(queryWrapper);
        return list;
    }
    /**
     * 条件查询;
     */
    public BrothersSistersPeople slectQueryGetOne(String query){
        QueryWrapper<BrothersSistersPeople> queryWrapper = QueryWrapperVO.getQueryWrapper(query);
        BrothersSistersPeople list = brothersSistersPeopleMapper.selectOne(queryWrapper);
        return list;
    }


    /**
     * 删除兄弟姐妹之间的关系;
     */
    public void  delBrother(BrothersSistersPeople brothersSistersPeople){
        brothersSistersPeopleMapper.deleteById(brothersSistersPeople.getId());
    }



}
